// 房间与房间特征 - Hotel
import { get } from 'lodash';
import { DataTypes, UUIDV4 } from 'sequelize';
import { MySqlModel, getSequelize } from '../db';

class RoomRoomFeature extends MySqlModel {

}

RoomRoomFeature.init({
  id: {
    type: DataTypes.UUID, unique: 'id', allowNull: false, defaultValue: UUIDV4, validate: { isUUID: 4 }, primaryKey: true, comment: '主键'
  },
  hotel_id: {
    type: DataTypes.UUID, allowNull: false, validate: { isUUID: 4 }, comment: '主体'
  },
  room_id: {
    type: DataTypes.UUID, unique: 'room_room_feature_id', allowNull: false, validate: { isUUID: 4 }, comment: '房号'
  },
  room_feature_id: {
    type: DataTypes.UUID, unique: 'room_room_feature_id', allowNull: false, validate: { isUUID: 4 }, comment: '房间特征'
  },
  created_at: {
    type: DataTypes.DATE, allowNull: false, comment: '创建时间'
  },
  updated_at: {
    type: DataTypes.DATE, allowNull: false, comment: '更新时间'
  },
  version: {
    type: DataTypes.INTEGER, allowNull: false, defaultValue: 0, comment: '版本控制'
  }
}, {
  sequelize: getSequelize(),
  tableName: 'room_room_features',
  comment: '房间与房间特征关联'
});

// RoomRoomFeature.associate = (models) => {
//   RoomRoomFeature.hasOne(models.Room, {
//     sourceKey: 'id',
//     foreignKey: 'room_id',
//     as: 'room',
//     constraints: false
//   });

//   RoomRoomFeature.hasOne(models.RoomFeature, {
//     sourceKey: 'id',
//     foreignKey: 'room_feature_id',
//     as: 'room_feature',
//     constraints: false
//   });
// };

export default RoomRoomFeature;
